﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RepositoryAndEf.Core.Data;
using RepositoryAndEf.Domain;
using Rhino.Mocks;
using System.Collections.Generic;
using System.Collections;
using System.Linq;

namespace RepositoryAndEf.Core.Tests.Domain
{
    [TestClass]
    public class OrderFactoryTests
    {
        [TestMethod]
        public void Can_CreateOrder()
        {
            var orderFactory = new OrderFactory();
            var cart = new ShoppingCart
            {
                Id = Guid.NewGuid(),
                Customer = new User
                {
                    Id = Guid.NewGuid(),
                    Name = "Jesse",
                },
            };

            cart.Items = new List<ShoppingCartItem>(){
                new ShoppingCartItem
                {
                    Id = Guid.NewGuid(),
                    Product = new Product
                       {
                           Id = Guid.NewGuid(),
                           Price = 200,
                           Title = "20公斤一副公斤10两只可拆卸电镀哑铃铸铁材质 家用健身器材"
                       },
                    Quantity = 1,
                }
            };


            var order = orderFactory.Create(cart);

            Assert.IsNotNull(order);
            Assert.IsNotNull(order.Items);
            Assert.AreEqual(1, order.Items.ToList().Count);
            Assert.AreEqual("Jesse", order.Customer.Name);
        }
    }
}
